import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/models/chat_message/xindong_custom_gift_message.dart';
import 'package:xindong/models/chat_message/xindong_custom_message.dart';
import 'package:xindong/utils/xindong_conversion_util.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:xindong/widgets/xindong_avatar.dart';

class XinDongPiaoPingGiftCell extends StatelessWidget {
  static TextStyle nameTextStyle = const TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.orange, height: 1.2);
  static TextStyle textTextStyle = const TextStyle(fontSize: 14, color: Colors.white, height: 1.2);
  final double itemHeight;
  final XinDongCustomGiftMessage message;

  const XinDongPiaoPingGiftCell({Key? key, required this.message, required this.itemHeight}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: itemHeight,
      width: screenWidth,
      padding: const EdgeInsets.only(left: 16, right: 16),
      child: Stack(
        fit: StackFit.expand,
        children: [
          /// 背景
          Container(
            height: double.infinity,
            width: double.infinity,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(itemHeight),
              // 渐变色
              gradient: const LinearGradient(
                begin: Alignment.centerLeft,
                end: Alignment.centerRight,
                colors: [DZColors.mainColor, DZColors.mainLightColor],
              ),
            ),
          ),
          // ImageHelper.assetImage("image_floating_screen", fit: BoxFit.fill),
          Container(
            width: double.infinity,
            padding: const EdgeInsets.only(left: 15, right: 8),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                // XinDongAvatarBorder(message.sender!, avatarSize: 32),
                // const SizedBox(width: 4),
                Text(message.user_name, maxLines: 1, overflow: TextOverflow.ellipsis, style: nameTextStyle),
                Text(" 送出 ", style: textTextStyle),
                Flexible(
                  child: Text(
                    XinDongConversionUtil.xindong_breakWord("${message.gift_name}x${message.gift_num}"),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: textTextStyle,
                  ),
                ),
                const SizedBox(width: 20),
                SizedBox(
                  width: itemHeight,
                  height: itemHeight,
                  child: OverflowBox(
                    maxHeight: 70,
                    maxWidth: 70,
                    alignment: Alignment.bottomCenter,
                    child: Stack(
                      fit: StackFit.expand,
                      clipBehavior: Clip.none,
                      children: [
                        Positioned(
                          top: 10,
                          width: 70,
                          height: 70,
                          child: ImageUtil.networkImageUrl(
                            message.gift_preview,
                            placeholder: const SizedBox(),
                            errorWidget: const SizedBox(),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
